package com.todo.biz.infrastructure.repository.impl;


import com.todo.biz.infrastructure.entity.po.BaseDictPO;
import com.todo.biz.infrastructure.mapper.BaseDictMapper;
import com.todo.biz.infrastructure.repository.BaseDictRepository;
import com.todo.common.utils.StringUtils;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/12/9 15:29
 * @description
 */
@Repository
public class BaseDictRepositoryImpl implements BaseDictRepository {

    @Resource
    private BaseDictMapper baseDictMapper;

    @Override
    public BaseDictPO queryBaseDictPOById(Long id) {
        if (id == null || id < 0) {
            return null;
        }
        return baseDictMapper.queryBaseDictById(id);
    }

    @Override
    public Boolean updateBaseDictPOById(BaseDictPO baseDictPO) {
        if (baseDictPO == null || baseDictPO.getId() == null || StringUtils.isBlank(baseDictPO.getValues())) {
            return false;
        }
        return baseDictMapper.updateBaseDictById(baseDictPO);
    }

    @Override
    public Boolean insertBaseDict(BaseDictPO baseDictPO) {
        if (baseDictPO == null || StringUtils.isBlank(baseDictPO.getValues()) || StringUtils.isBlank(baseDictPO.getBizCode()) || StringUtils.isBlank(baseDictPO.getSceneCode())) {
            return false;
        }
        return baseDictMapper.insertBaseDict(baseDictPO);
    }

    @Override
    public Boolean removeBaseDictPOById(Long id) {
        if (id == null || id < 0) {
            return true;
        }
        return baseDictMapper.removeBaseDictById(id);
    }

    @Override
    public BaseDictPO queryBaseDictByBizCodeAndSceneCode(String bizCode, String sceneCode) {
        if (StringUtils.isBlank(bizCode) || StringUtils.isBlank(sceneCode)) {
            return null;
        }
        return baseDictMapper.queryBaseDictByBizCodeAndSceneCode(bizCode, sceneCode);
    }

    @Override
    public List<BaseDictPO> queryBaseDictList() {
        return baseDictMapper.queryBaseDictList();
    }
}
